function getusertext() {
    $.ajax({
        url: '/my/user/userinfo',
        type: 'get',
        success: function (res) {
            console.log(res)
            if (res.status == 0) {
                let name = res.data.nickname || res.data.username
                $('.username').text(name)


                let pic = res.data.user_pic
                if (pic) {
                    $('.layui-nav-img').attr('src', pic).show()
                } else {
                    //选取下标为0的选一位元素并且大写
                    let fis = res.data.username.substring(0, 1).toUpperCase()
                    // let fis = res.data.username.substring(0, 3).toUpperCase()
                    $('.useroo').text(fis).css('display', 'inline-block')
                }
            }
        }
    })


}
getusertext()

$('.end').on('click', function (e) {
    e.preventDefault()
    layer.confirm('确定要退出吗', function (index) {
        localStorage.removeItem('token')
        location.href = './loge.htm'
        layer.close(index);
    })
})